package br.com.fogas.database;

import java.sql.SQLException;

import com.j256.ormlite.support.ConnectionSource;

import android.content.Context;
import br.com.fogas.database.dao.impl.A903Dao;
import br.com.fogas.database.dao.impl.A942Dao;
import br.com.fogas.database.dao.impl.A951Dao;
import br.com.fogas.database.dao.impl.A952Dao;
import br.com.fogas.database.dao.impl.A957Dao;
import br.com.fogas.database.dao.impl.A962Dao;
import br.com.fogas.database.dao.impl.A963Dao;
import br.com.fogas.database.dao.impl.A965Dao;
import br.com.fogas.database.dao.impl.A966Dao;
import br.com.fogas.database.dao.impl.A970Dao;
import br.com.fogas.database.dao.impl.A971Dao;
import br.com.fogas.database.dao.impl.A972Dao;
import br.com.fogas.database.dao.impl.A973Dao;
import br.com.fogas.database.dao.impl.A975Dao;
import br.com.fogas.database.dao.impl.A976Dao;
import br.com.fogas.database.dao.impl.A977Dao;
import br.com.fogas.database.dao.impl.A979Dao;
import br.com.fogas.database.dao.impl.A982Dao;
import br.com.fogas.database.dao.impl.A983Dao;
import br.com.fogas.database.dao.impl.A987Dao;
import br.com.fogas.database.dao.impl.CanalDao;
import br.com.fogas.database.dao.impl.ClienteDao;
import br.com.fogas.database.dao.impl.CondicaoPagtoDao;
import br.com.fogas.database.dao.impl.ConfigDao;
import br.com.fogas.database.dao.impl.MaterialDao;
import br.com.fogas.database.dao.impl.MedidorDao;
import br.com.fogas.database.dao.impl.MedidorHistDao;
import br.com.fogas.database.dao.impl.NotaControleDao;
import br.com.fogas.database.dao.impl.NotaFiscalDao;
import br.com.fogas.database.dao.impl.NotaItemCondicoesDao;
import br.com.fogas.database.dao.impl.NotaItemDao;
import br.com.fogas.database.dao.impl.NotaOcorrenciaDao;
import br.com.fogas.database.dao.impl.PlanoVisitasDao;

public class FogasDatabase {
	
	private DatabaseHelper helper;
	
	private ConnectionSource connectionSource;
	
	private CondicaoPagtoDao condicaoPagamento;
	
	private ClienteDao cliente;
	
	private MedidorDao medidor;
	
	private MedidorHistDao medidorHistorico;
	
	private ConfigDao config;
	
	private CanalDao canal;
	
	private PlanoVisitasDao planoVisitas;
	
	private A903Dao A903;
	
	private A942Dao A942;
	
	private A951Dao A951;
	
	private A952Dao A952;
	
	private A957Dao A957;
	
	private A962Dao A962;
	
	private A963Dao A963;
	
	private A965Dao A965;
	
	private A966Dao A966;
	
	private A970Dao A970;
	
	private A971Dao A971;
	
	private A972Dao A972;
	
	private A973Dao A973;
	
	private A975Dao A975;
	
	private A976Dao A976;
	
	private A977Dao A977;
	
	private A979Dao A979;
	
	private A982Dao A982;
	
	private A983Dao A983;
	
	private A987Dao A987;
	
	private MaterialDao material;
	
	private NotaControleDao notaControle;
	
	private NotaFiscalDao notaFiscal;
	
	private NotaItemDao notaItem;
	
	private NotaItemCondicoesDao notaCondicoes;
	
	private NotaOcorrenciaDao notaOcorrencia;
	
	public FogasDatabase(Context context) {
		this.helper = new DatabaseHelper(context);
		this.connectionSource = getHelper().getConnectionSource();
	}
	
	public ConfigDao getConfig() throws SQLException {
		if(config == null) {
			this.config = new ConfigDao(getConnectionSource());
		}
		return config;
	}
	
	public MedidorHistDao getMedidorHistorico() throws SQLException {
		if(medidorHistorico == null) {
			this.medidorHistorico = new MedidorHistDao(this);
		}
		return medidorHistorico;
	}
	
	public CondicaoPagtoDao getCondicaoPagamento() throws SQLException {
		if(condicaoPagamento == null) {
			this.condicaoPagamento = new CondicaoPagtoDao(getConnectionSource());
		}
		return condicaoPagamento;
	}
	
	public ClienteDao getCliente() throws SQLException {
		if(cliente == null) {
			this.cliente = new ClienteDao(this);
		}
		return cliente;
	}
	
	public MedidorDao getMedidor() throws SQLException {
		if(medidor == null) {
			this.medidor = new MedidorDao(this);
		}
		return medidor;
	}
	
	public CanalDao getCanal() throws SQLException {
		if(canal == null) {
			this.canal = new CanalDao(getConnectionSource());
		}
		return canal;
	}
	
	public PlanoVisitasDao getPlanoVisitas() throws SQLException {
		if(planoVisitas == null) {
			this.planoVisitas = new PlanoVisitasDao(getConnectionSource());
		}
		return planoVisitas;
	}
	
	public A903Dao getA903() throws SQLException {
		if(A903 == null) {
			this.A903 = new A903Dao(getConnectionSource());
		}
		return A903;
	}

	public A942Dao getA942() throws SQLException {
		if(A942 == null) {
			this.A942 = new A942Dao(getConnectionSource());
		}
		return A942;
	}

	public A951Dao getA951() throws SQLException {
		if(A951 == null) {
			this.A951 = new A951Dao(getConnectionSource());
		}
		return A951;
	}
	
	public A952Dao getA952() throws SQLException {
		if(A952 == null) {
			this.A952 = new A952Dao(getConnectionSource());
		}
		return A952;
	}

	public A957Dao getA957() throws SQLException {
		if(A957 == null) {
			this.A957 = new A957Dao(getConnectionSource());
		}
		return A957;
	}

	public A962Dao getA962() throws SQLException {
		if(A962 == null) {
			this.A962 = new A962Dao(getConnectionSource());
		}
		return A962;
	}

	public A963Dao getA963() throws SQLException {
		if(A963 == null) {
			this.A963 = new A963Dao(getConnectionSource());
		}
		return A963;
	}

	public A965Dao getA965() throws SQLException {
		if(A965 == null) {
			this.A965 = new A965Dao(getConnectionSource());
		}
		return A965;
	}

	public A966Dao getA966() throws SQLException {
		if(A966 == null) {
			this.A966 = new A966Dao(getConnectionSource());
		}
		return A966;
	}

	public A970Dao getA970() throws SQLException {
		if(A970 == null) {
			this.A970 = new A970Dao(getConnectionSource());
		}
		return A970;
	}

	public A971Dao getA971() throws SQLException {
		if(A971 == null) {
			this.A971 = new A971Dao(getConnectionSource());
		}
		return A971;
	}

	public A972Dao getA972() throws SQLException {
		if(A972 == null) {
			this.A972 = new A972Dao(getConnectionSource());
		}
		return A972;
	}

	public A973Dao getA973() throws SQLException {
		if(A973 == null) {
			this.A973 = new A973Dao(getConnectionSource());
		}
		return A973;
	}

	public A975Dao getA975() throws SQLException {
		if(A975 == null) {
			this.A975 = new A975Dao(getConnectionSource());
		}
		return A975;
	}

	public A976Dao getA976() throws SQLException {
		if(A976 == null) {
			this.A976 = new A976Dao(getConnectionSource());
		}
		return A976;
	}

	public A977Dao getA977() throws SQLException {
		if(A977 == null) {
			this.A977 = new A977Dao(getConnectionSource());
		}
		return A977;
	}

	public A979Dao getA979() throws SQLException {
		if(A979 == null) {
			this.A979 = new A979Dao(getConnectionSource());
		}
		return A979;
	}

	public A982Dao getA982() throws SQLException {
		if(A982 == null) {
			this.A982 = new A982Dao(getConnectionSource());
		}
		return A982;
	}

	public A983Dao getA983() throws SQLException {
		if(A983 == null) {
			this.A983 = new A983Dao(getConnectionSource());
		}
		return A983;
	}

	public A987Dao getA987() throws SQLException {
		if(A987 == null) {
			this.A987 = new A987Dao(getConnectionSource());
		}
		return A987;
	}
	
	public MaterialDao getMaterial() throws SQLException {
		if(material == null) {
			this.material = new MaterialDao(getConnectionSource());
		}
		return material;
	}
	
	public NotaControleDao getNotaControle() throws SQLException {
		if(notaControle == null) {
			this.notaControle = new NotaControleDao(getConnectionSource());
		}
		return notaControle;
	}
	
	public NotaFiscalDao getNotaFiscal() throws SQLException {
		if(notaFiscal == null) {
			this.notaFiscal = new NotaFiscalDao(this);
		}
		return notaFiscal;
	}
	
	public NotaItemDao getNotaItem() throws SQLException {
		if(notaItem == null) {
			this.notaItem = new NotaItemDao(getConnectionSource());
		}
		return notaItem;
	}
	
	public NotaItemCondicoesDao getNotaCondicoes() throws SQLException {
		if(notaCondicoes == null) {
			this.notaCondicoes = new NotaItemCondicoesDao(getConnectionSource());
		}
		return notaCondicoes;
	}
	
	public NotaOcorrenciaDao getNotaOcorrencia() throws SQLException {
		if(notaOcorrencia == null) {
			this.notaOcorrencia = new NotaOcorrenciaDao(this);
		}
		return notaOcorrencia;
	}

	public DatabaseHelper getHelper() {
		return helper;
	}
	
	public ConnectionSource getConnectionSource() {
		return connectionSource;
	}
	
	public void fecharConexao() {
		helper.close();
	}
}